﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.RobotJog.Controls.Joints.JointsLayoutBuilder
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.RobotJog.Controls.Joints;

internal abstract class JointsLayoutBuilder
{
  protected CUiJointsControl jointsControl;
  protected CApRJRobotJogJointsLogic jointJogApplication;

  internal JointsLayoutBuilder(
    CUiJointsControl jointsControl,
    CApRJRobotJogJointsLogic jointJogApplication)
  {
    this.jointJogApplication = jointJogApplication;
    this.jointsControl = jointsControl;
  }

  public abstract void AditionalGridInit();

  public abstract void AddJointToGrid(CUiJointNodeData jointData);

  public abstract CUiJointNodeData GetJoinData(FrameworkElement element);

  public abstract int JointsCountInGrid();

  public virtual void InitGrid() => this.CreateColumnHeaders();

  private void CreateColumnHeaders()
  {
    string name = this.jointsControl.jointsGrid.ColumnDefinitions[this.jointsControl.jointsGrid.ColumnDefinitions.Count - 1].Name;
    Border border1 = new Border();
    border1.BorderThickness = new Thickness(1.0);
    TextBlock textBlock1 = new TextBlock();
    textBlock1.Text = RJRobotJogResources.Joints_JointColumnNiceName;
    textBlock1.HorizontalAlignment = HorizontalAlignment.Center;
    textBlock1.VerticalAlignment = VerticalAlignment.Center;
    border1.Child = (UIElement) textBlock1;
    Border jointNameBorder = border1;
    if (name != ColumnsIDS.Joint)
      jointNameBorder.Margin = new Thickness(0.0, 0.0, -7.0, 0.0);
    Border border2 = new Border();
    border2.BorderThickness = new Thickness(0.0, 1.0, 1.0, 1.0);
    TextBlock textBlock2 = new TextBlock();
    textBlock2.Text = RJRobotJogResources.Joints_ValueColumnNiceName;
    textBlock2.HorizontalAlignment = HorizontalAlignment.Center;
    textBlock2.VerticalAlignment = VerticalAlignment.Center;
    border2.Child = (UIElement) textBlock2;
    Border border3 = border2;
    Grid.SetColumnSpan((UIElement) border3, 3);
    if (name != ColumnsIDS.Value)
      border3.Margin = new Thickness(0.0, 0.0, -7.0, 0.0);
    Border border4 = new Border();
    border4.BorderThickness = new Thickness(0.0, 1.0, 1.0, 1.0);
    TextBlock textBlock3 = new TextBlock();
    textBlock3.Text = "%";
    textBlock3.HorizontalAlignment = HorizontalAlignment.Center;
    textBlock3.VerticalAlignment = VerticalAlignment.Center;
    textBlock3.ToolTip = (object) RJRobotJogResources.Joints_PercentageColumnNiceName;
    border4.Child = (UIElement) textBlock3;
    Border percentageBorder = border4;
    if (name != ColumnsIDS.Percentage)
      percentageBorder.Margin = new Thickness(0.0, 0.0, -7.0, 0.0);
    Border lowSoftLimitBorder = new Border()
    {
      BorderThickness = new Thickness(0.0, 1.0, 1.0, 1.0)
    };
    ImageSource imageSource1 = TxImageManager.GetImageByKey("LowerLimit").ConvertTo<ImageSource>(new System.Drawing.Size());
    Border border5 = lowSoftLimitBorder;
    System.Windows.Controls.Image image1 = new System.Windows.Controls.Image();
    image1.Source = imageSource1;
    image1.HorizontalAlignment = HorizontalAlignment.Center;
    image1.VerticalAlignment = VerticalAlignment.Center;
    image1.Height = 11.0;
    image1.Width = 19.0;
    image1.ToolTip = (object) RJRobotJogResources.Joints_LowerSoftLimitNiceName;
    border5.Child = (UIElement) image1;
    if (name != ColumnsIDS.LowerLimit)
      lowSoftLimitBorder.Margin = new Thickness(0.0, 0.0, -7.0, 0.0);
    Border upperSoftLimitBorder = new Border()
    {
      BorderThickness = new Thickness(0.0, 1.0, 1.0, 1.0)
    };
    ImageSource imageSource2 = TxImageManager.GetImageByKey("UpperLimit").ConvertTo<ImageSource>(new System.Drawing.Size());
    Border border6 = upperSoftLimitBorder;
    System.Windows.Controls.Image image2 = new System.Windows.Controls.Image();
    image2.Source = imageSource2;
    image2.HorizontalAlignment = HorizontalAlignment.Center;
    image2.VerticalAlignment = VerticalAlignment.Center;
    image2.Height = 11.0;
    image2.Width = 19.0;
    image2.ToolTip = (object) RJRobotJogResources.Joints_UpperSoftLimitNiceName;
    border6.Child = (UIElement) image2;
    if (name != ColumnsIDS.UpperLimit)
      upperSoftLimitBorder.Margin = new Thickness(0.0, 0.0, -7.0, 0.0);
    this.jointsControl.AddRowToGrid((CUiJointNodeData) null, jointNameBorder, border3, (Border) null, percentageBorder, lowSoftLimitBorder, upperSoftLimitBorder);
  }
}
